Test Setup Failed
Push — develop ( 9b48a4...b87ace )
by Aristeides
02:13
created

kirkiSetSettingValue.set   D

Complexity

Conditions 26
Paths 29

Size

Total Lines 1

Duplication

Lines 1
Ratio 100 %

Importance

Changes 0
Metric Value
cc 26
nc 29
nop 2
dl 1
loc 1
rs 4.5382
c 0
b 0
f 0

How to fix   Complexity   

Complexity

Complex classes like kirkiSetSettingValue.set often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

1
if(_.isUndefined(window.kirkiSetSettingValue))var kirkiSetSettingValue={set:function(e,t){var i,n=this,a=wp.customize.settings.controls[e];if(_.isUndefined(a))return!0;switch(n.setValue(e,t),a.type){case"kirki-background":_.isUndefined(t["background-color"])||n.setColorPicker(n.findElement(e,".kirki-color-control"),t["background-color"]),n.findElement(e,".placeholder, .thumbnail").removeClass().addClass("placeholder").html("No file selected"),_.each(["background-repeat","background-position"],function(i){_.isUndefined(t[i])||n.setSelectWoo(n.findElement(e,"."+i+" select"),t[i])}),_.each(["background-size","background-attachment"],function(i){jQuery(n.findElement(e,"."+i+' input[value="'+t+'"]')).prop("checked",!0)}),i=JSON.stringify(t).replace(/'/g,"&#39"),jQuery(n.findElement(e,".background-hidden-value").attr("value",i)).trigger("change");break;case"kirki-code":jQuery(n.findElement(e,".CodeMirror"))[0].CodeMirror.setValue(t);break;case"checkbox":case"kirki-switch":case"kirki-toggle":t=1===t||"1"===t||!0===t,jQuery(n.findElement(e,"input")).prop("checked",t),wp.customize.instance(e).set(t);break;case"kirki-select":case"kirki-preset":case"kirki-fontawesome":n.setSelectWoo(n.findElement(e,"select"),t);break;case"kirki-slider":jQuery(n.findElement(e,"input")).prop("value",t),jQuery(n.findElement(e,".kirki_range_value .value")).html(t);break;case"kirki-generic":(_.isUndefined(a.choices)||_.isUndefined(a.choices.element))&&(a.choices.element="input"),jQuery(n.findElement(e,a.choices.element)).prop("value",t);break;case"kirki-color":n.setColorPicker(n.findElement(e,".kirki-color-control"),t);break;case"kirki-multicheck":n.findElement(e,"input").each(function(){jQuery(this).prop("checked",!1)}),_.each(t,function(i,a){jQuery(n.findElement(e,'input[value="'+t[a]+'"]')).prop("checked",!0)});break;case"kirki-multicolor":_.each(t,function(t,i){n.setColorPicker(n.findElement(e,".multicolor-index-"+i),t)});break;case"kirki-radio-buttonset":case"kirki-radio-image":case"kirki-radio":case"kirki-dashicons":case"kirki-color-palette":case"kirki-palette":jQuery(n.findElement(e,'input[value="'+t+'"]')).prop("checked",!0);break;case"kirki-typography":_.each(["font-family","variant","subsets"],function(i){_.isUndefined(t[i])||n.setSelectWoo(n.findElement(e,"."+i+" select"),t[i])}),_.each(["font-size","line-height","letter-spacing","word-spacing"],function(i){_.isUndefined(t[i])||jQuery(n.findElement(e,"."+i+" input")).prop("value",t[i])}),_.isUndefined(t.color)||n.setColorPicker(n.findElement(e,".kirki-color-control"),t.color),i=JSON.stringify(t).replace(/'/g,"&#39"),jQuery(n.findElement(e,".typography-hidden-value").attr("value",i)).trigger("change");break;case"kirki-dimensions":_.each(t,function(t,i){jQuery(n.findElement(e,"."+i+" input")).prop("value",t)});break;case"kirki-repeater":case"kirki-custom":break;default:jQuery(n.findElement(e,"input")).prop("value",t)}},setColorPicker:function(e,t){e.attr("data-default-color",t).data("default-color",t).wpColorPicker("color",t)},setSelectWoo:function(e,t){jQuery(e).selectWoo().val(t).trigger("change")},setTextarea:function(e,t){jQuery(e).prop("value",t)},findElement:function(e,t){return wp.customize.control(e).container.find(t)},setValue:function(e,t,i){i=_.isUndefined(i)?100:parseInt(i,10),wp.customize.instance(e).set({}),setTimeout(function(){wp.customize.instance(e).set(t)},i)}};(kirki={initialized:!1,initialize:function(){this.initialized||(setTimeout(function(){kirki.util.webfonts.standard.initialize(),kirki.util.webfonts.google.initialize()},150),this.initialized=!0)}}).initialize();var kirki=kirki||{};kirki=(kirki=jQuery.extend(kirki,{control:{"kirki-radio":{init:function(e){this.template(e),kirki.input.radio.init(e)},template:function(e){var t=wp.template("kirki-input-radio");e.container.html(t({label:e.params.label,description:e.params.description,"data-id":e.id,inputAttrs:e.params.inputAttrs,default:e.params.default,value:kirki.setting.get(e.id),choices:e.params.choices}))}},"kirki-color":{init:function(e){this.template(e),kirki.input.color.init(e)},template:function(e){var t=wp.template("kirki-input-color");e.container.html(t({label:e.params.label,description:e.params.description,"data-id":e.id,mode:e.params.mode,inputAttrs:e.params.inputAttrs,"data-palette":e.params.palette,"data-default-color":e.params.default,"data-alpha":e.params.choices.alpha,value:kirki.setting.get(e.id)}))}},"kirki-generic":{init:function(e){this.template(e),_.isUndefined(e.params)||_.isUndefined(e.params.choices)||_.isUndefined(e.params.choices.element)||"textarea"!==e.params.choices.element?kirki.input.genericInput.init(e):kirki.input.textarea.init(e)},template:function(e){var t,i={label:e.params.label,description:e.params.description,"data-id":e.id,inputAttrs:e.params.inputAttrs,choices:e.params.choices,value:kirki.setting.get(e.id)};if(!_.isUndefined(e.params)&&!_.isUndefined(e.params.choices)&&!_.isUndefined(e.params.choices.element)&&"textarea"===e.params.choices.element)return t=wp.template("kirki-input-textarea"),void e.container.html(t(i));t=wp.template("kirki-input-generic"),e.container.html(t(i))}},"kirki-select":{init:function(e){this.template(e),kirki.input.select.init(e)},template:function(e){var t=wp.template("kirki-input-select");e.container.html(t({label:e.params.label,description:e.params.description,"data-id":e.id,inputAttrs:e.params.inputAttrs,choices:e.params.choices,value:kirki.setting.get(e.id),multiple:e.params.multiple||1,placeholder:e.params.placeholder}))}}}}))||{},kirki=(kirki=jQuery.extend(kirki,{input:{radio:{init:function(e){jQuery('input[data-id="'+e.id+'"]').on("change keyup paste click",function(){kirki.setting.set(e.id,jQuery(this).val())})}},color:{init:function(e){var t,i=jQuery('.kirki-color-control[data-id="'+e.id+'"]');e.choices=e.choices||{},_.isEmpty(e.choices)&&e.params.choices&&(e.choices=e.params.choices),_.isEmpty(e.choices)||i.wpColorPicker(e.choices),setTimeout(function(){(t=jQuery('.kirki-input-container[data-id="'+e.id+'"] .wp-picker-clear')).length&&t.click(function(){kirki.setting.set(e.id,"")})},200),i.wpColorPicker({change:function(){setTimeout(function(){kirki.setting.set(e.id,i.val())},20)}})}},genericInput:{init:function(e){jQuery('input[data-id="'+e.id+'"]').on("change keyup paste click",function(){kirki.setting.set(e.id,jQuery(this).val())})}},textarea:{init:function(e){jQuery('textarea[data-id="'+e.id+'"]').on("change keyup paste click",function(){kirki.setting.set(e.id,jQuery(this).val())})}},select:{init:function(e){var t,i=jQuery('select[data-id="'+e.id+'"]'),n=parseInt(i.data("multiple"),10),a={escapeMarkup:function(e){return e}};e.params.placeholder&&(a.placeholder=e.params.placeholder,a.allowClear=!0),1<n&&(a.maximumSelectionLength=n),jQuery(i).selectWoo(a).on("change",function(){t=null===(t=jQuery(this).val())&&1<n?[]:t,kirki.setting.set(e.id,t)})}},image:{getTemplate:function(e){var t,i="";return e=_.defaults(e,{label:"",description:"",inputAttrs:"","data-id":"",choices:{},value:""}),_.isUndefined(e.choices)||_.isUndefined(e.choices.save_as)||e.choices.save_as,t=e.value,_.isObject(e.value)&&!_.isUndefined(e.value.url)&&(t=e.value.url),i+="<label>",e.label&&(i+='<span class="customize-control-title">'+e.label+"</span>"),e.description&&(i+='<span class="description customize-control-description">'+e.description+"</span>"),i+="</label>",i+='<div class="image-wrapper attachment-media-view image-upload">',e.value.url||""!==t?i+='<div class="thumbnail thumbnail-image"><img src="'+t+'" alt="" /></div>':i+='<div class="placeholder">'+kirkiL10n.noFileSelected+"</div>",i+='<div class="actions">',i+='<button class="button image-upload-remove-button'+(""===t?" hidden":"")+'">'+kirkiL10n.remove+"</button>",e.default&&""!==e.default&&(i+='<button type="button" class="button image-default-button"',(e.default===e.value||!_.isUndefined(e.value.url)&&e.default===e.value.url)&&(i+=' style="display:none;"'),i+=">"+kirkiL10n.default+"</button>"),i+='<button type="button" class="button image-upload-button">'+kirkiL10n.selectFile+"</button>",i+="</div></div>",'<div class="kirki-input-container" data-id="'+e.id+'">'+i+"</div>"},init:function(e){}}}}))||{},kirki=(kirki=jQuery.extend(kirki,{setting:{get:function(e){var t=e.split("["),i="",n=0,a="";return _.each(t,function(e,t){e=e.replace("]",""),0===t?i=e:i+="["+e+"]",_.isUndefined(wp.customize.instance(i))||(a=wp.customize.instance(i).get(),n=t),n<t&&_.isObject(a)&&!_.isUndefined(a[e])&&(a=a[e])}),a},set:function(e,t,i){var n,a,r,s,o,c="",l="",u={};n=e,_.isObject(e)&&(n=jQuery(e).attr("data-id")?e.attr("data-id"):e.parents("[data-id]").attr("data-id")),void 0===wp.customize.control(n)?(a=n.split("["),_.each(a,function(e,t){e=e.replace("]",""),c=0===t?e:"["+e+"]",_.isUndefined(wp.customize.instance(c))||(l=c,r=wp.customize.instance(l).get())}),""!==(s=n.replace(l,""))?(_.isObject(r)||(r={}),"["===s.charAt(0)&&(s=s.replace("[","")),o=s.split("["),_.each(o,function(e,t){o[t]=e.replace("]","")}),i&&o.push(i),u='{"'+o.join('":{"')+'":"'+t+'"'+"}".repeat(o.length),u=JSON.parse(u),jQuery.extend(!0,r,u),t=r):i&&((r=_.isObject(r)?r:{})[i]=t,t=r),wp.customize.control(l).setting.set(t)):wp.customize.control(n).setting.set(t)}}}))||{};kirki=jQuery.extend(kirki,{util:{webfonts:{google:{fonts:{},initialize:function(){this.setFonts()},setFonts:function(){var e=this;_.isEmpty(e.fonts)&&jQuery.post(ajaxurl,{action:"kirki_fonts_google_all_get"},function(t){e.fonts=JSON.parse(t)})},getFont:function(e){var t=this.getFonts();return void 0!==t[e]&&t[e]},getFonts:function(e,t){var i=this,n={},a=[];return e=e||"alpha",e="alpha"!==e&&"popularity"!==e&&"trending"!==e?"alpha":e,t=t||0,t=parseInt(t,10),"alpha"===e||0===t?n=i.fonts.items:(a=_.first(i.fonts.order[e],t),_.each(a,function(e){n[e]=i.fonts.items[e]})),n},getVariants:function(e){var t=this.getFont(e);return!!t&&(!_.isUndefined(t.variants)&&t.variants)},getSubsets:function(e){var t=this.getFont(e);return!!t&&(!_.isUndefined(t.subsets)&&t.subsets)}},standard:{fonts:{},initialize:function(){this.setFonts()},setFonts:function(){var e=this;_.isEmpty(e.fonts)&&jQuery.post(ajaxurl,{action:"kirki_fonts_standard_all_get"},function(t){e.fonts=JSON.parse(t)})},getVariants:function(e){return["regular","italic","700","700italic"]}},getFontType:function(e){return void 0!==this.standard.fonts[e]||void 0!==this.standard.fonts.stack&&void 0!==this.standard.fonts.stack[e]?"standard":void 0!==this.google.fonts.items[e]&&"google"}}}}),function(){"use strict";wp.customize.kirkiDynamicControl=wp.customize.Control.extend({initialize:function(e,t){var i=t||{};i.params=i.params||{},i.params.type||(i.params.type="kirki-generic"),i.params.content||(i.params.content=jQuery("<li></li>"),i.params.content.attr("id","customize-control-"+e.replace(/]/g,"").replace(/\[/g,"-")),i.params.content.attr("class","customize-control customize-control-"+i.params.type)),this.propertyElements=[],wp.customize.Control.prototype.initialize.call(this,e,i)},_setUpSettingRootLinks:function(){var e=this;e.container.find("[data-customize-setting-link]").each(function(){var t=jQuery(this);wp.customize(t.data("customizeSettingLink"),function(i){var n=new wp.customize.Element(t);e.elements.push(n),n.sync(i),n.set(i())})})},_setUpSettingPropertyLinks:function(){var e=this;e.setting&&e.container.find("[data-customize-setting-property-link]").each(function(){var t,i=jQuery(this),n=i.data("customizeSettingPropertyLink");t=new wp.customize.Element(i),e.propertyElements.push(t),t.set(e.setting()[n]),t.bind(function(t){var i=e.setting();t!==i[n]&&((i=_.clone(i))[n]=t,e.setting.set(i))}),e.setting.bind(function(e){e[n]!==t.get()&&t.set(e[n])})})},ready:function(){var e=this;e._setUpSettingRootLinks(),e._setUpSettingPropertyLinks(),wp.customize.Control.prototype.ready.call(e),e.deferred.embedded.done(function(){e.initKirkiControl(e)})},embed:function(){var e=this,t=e.section();t&&wp.customize.section(t,function(t){"kirki-expanded"===t.params.type||t.expanded()||wp.customize.settings.autofocus.control===e.id?e.actuallyEmbed():t.expanded.bind(function(t){t&&e.actuallyEmbed()})})},actuallyEmbed:function(){"resolved"!==this.deferred.embedded.state()&&(this.renderContent(),this.deferred.embedded.resolve())},focus:function(e){this.actuallyEmbed(),wp.customize.Control.prototype.focus.call(this,e)},initKirkiControl:function(e){void 0===kirki.control[e.params.type]?this.container.on("change keyup paste click","input",function(){e.setting.set(jQuery(this).val())}):kirki.control[e.params.type].init(e)},kirkiValidateCSSValue:function(e){var t,i;return"0"===e||0<=e.indexOf("calc(")&&0<=e.indexOf(")")||("auto"===e||"inherit"===e||"initial"===e||(t=parseFloat(e),i=e.replace(t,""),!isNaN(t)&&-1!==jQuery.inArray(i,["rem","em","ex","%","px","cm","mm","in","pt","pc","ch","vh","vw","vmin","vmax"])))}})}(),_.each(kirki.control,function(e,t){wp.customize.controlConstructor[t]=wp.customize.kirkiDynamicControl.extend({})}),wp.customize.controlConstructor["kirki-background"]=wp.customize.Control.extend({ready:function(){"use strict";!_.isUndefined(window.kirkiControlLoader)&&_.isFunction(kirkiControlLoader)?kirkiControlLoader(this):this.initKirkiControl()},initKirkiControl:function(){var e=this,t=e.getValue(),i=e.container.find(".kirki-color-control");(_.isUndefined(t["background-image"])||""===t["background-image"])&&(e.container.find(".background-wrapper > .background-repeat").hide(),e.container.find(".background-wrapper > .background-position").hide(),e.container.find(".background-wrapper > .background-size").hide(),e.container.find(".background-wrapper > .background-attachment").hide()),i.wpColorPicker({change:function(){setTimeout(function(){e.saveValue("background-color",i.val())},100)}}),e.container.on("change",".background-repeat select",function(){e.saveValue("background-repeat",jQuery(this).val())}),e.container.on("change click",".background-size input",function(){e.saveValue("background-size",jQuery(this).val())}),e.container.on("change",".background-position select",function(){e.saveValue("background-position",jQuery(this).val())}),e.container.on("change click",".background-attachment input",function(){e.saveValue("background-attachment",jQuery(this).val())}),e.container.on("click",".background-image-upload-button",function(t){var i=wp.media({multiple:!1}).open().on("select",function(){var t,n,a,r=i.state().get("selection").first(),s=r.toJSON().sizes.full.url;_.isUndefined(r.toJSON().sizes.medium)?_.isUndefined(r.toJSON().sizes.thumbnail)||(s=r.toJSON().sizes.thumbnail.url):s=r.toJSON().sizes.medium.url,t=r.toJSON().sizes.full.url,r.toJSON().id,r.toJSON().width,r.toJSON().height,""!==t&&e.container.find(".background-wrapper > .background-repeat, .background-wrapper > .background-position, .background-wrapper > .background-size, .background-wrapper > .background-attachment").show(),e.saveValue("background-image",t),n=e.container.find(".placeholder, .thumbnail"),a=e.container.find(".background-image-upload-remove-button"),n.length&&n.removeClass().addClass("thumbnail thumbnail-image").html('<img src="'+s+'" alt="" />'),a.length&&a.show()});t.preventDefault()}),e.container.on("click",".background-image-upload-remove-button",function(t){var i,n;t.preventDefault(),e.saveValue("background-image",""),i=e.container.find(".placeholder, .thumbnail"),n=e.container.find(".background-image-upload-remove-button"),e.container.find(".background-wrapper > .background-repeat").hide(),e.container.find(".background-wrapper > .background-position").hide(),e.container.find(".background-wrapper > .background-size").hide(),e.container.find(".background-wrapper > .background-attachment").hide(),i.length&&i.removeClass().addClass("placeholder").html("No file selected"),n.length&&n.hide()})},getValue:function(){var e=this,t={};return _.each(e.params.default,function(i,n){!1!==i&&(t[n]=i,_.isUndefined(e.setting._value[n])||(t[n]=e.setting._value[n]))}),_.each(e.setting._value,function(e,i){_.isUndefined(t[i])&&(t[i]=e)}),t},saveValue:function(e,t){"use strict";var i=jQuery("#customize-control-"+this.id.replace("[","-").replace("]","")+" .background-hidden-value"),n=jQuery(i).val(),a=JSON.parse(n);a[e]=t,this.setting.set(a),jQuery(i).attr("value",JSON.stringify(a)).trigger("change")}}),wp.customize.controlConstructor["kirki-color-palette"]=wp.customize.kirkiDynamicControl.extend({}),wp.customize.controlConstructor["kirki-dashicons"]=wp.customize.kirkiDynamicControl.extend({}),wp.customize.controlConstructor["kirki-date"]=wp.customize.kirkiDynamicControl.extend({initKirkiControl:function(){_.isUndefined(wp.customize.DateTimeControl)||wp.customize.control.add(new wp.customize.DateTimeControl(this.id,{section:this.params.section,priority:this.params.priority,label:this.params.label,description:this.params.description,settings:{default:this.id},default:this.params.default}))}}),wp.customize.controlConstructor["kirki-dimension"]=wp.customize.kirkiDynamicControl.extend({initKirkiControl:function(){var e,t=this;t.kirkiNotifications(),this.container.on("change keyup paste","input",function(){e=jQuery(this).val(),t.setting.set(e)})},kirkiNotifications:function(){var e=this;wp.customize(e.id,function(t){t.bind(function(i){var n="long_title";!1===e.kirkiValidateCSSValue(i)?t.notifications.add(n,new wp.customize.Notification(n,{type:"warning",message:dimensionkirkiL10n["invalid-value"]})):t.notifications.remove(n)})})}}),wp.customize.controlConstructor["kirki-dimensions"]=wp.customize.kirkiDynamicControl.extend({initKirkiControl:function(){var e,t=this.params.choices.controls,i={},n=[];for(_.each(t,function(e,t){!0===e&&n.push(t)}),e=0;e<n.length;e++)i[n[e]]=this.setting._value[n[e]],this.updateDimensionsValue(n[e],i)},updateDimensionsValue:function(e,t){var i=this;i.container.on("change keyup paste","."+e+" input",function(){t[e]=jQuery(this).val(),i.kirkiNotifications(),i.saveValue(t)})},saveValue:function(e){var t={};_.each(e,function(e,i){t[i]=e}),this.setting.set(t)},kirkiNotifications:function(){var e=this;wp.customize(e.id,function(t){t.bind(function(i){var n,a="long_title",r={};if(t.notifications.remove(a),_.each(i,function(t,i){!1===e.kirkiValidateCSSValue(t)?r[i]=t:delete r[i]}),!_.isEmpty(r))return n=dimensionskirkiL10n["invalid-value"]+" ("+_.values(r).toString()+") ",void t.notifications.add(a,new wp.customize.Notification(a,{type:"warning",message:n}));t.notifications.remove(a)})})}}),wp.customize.controlConstructor["kirki-editor"]=wp.customize.kirkiDynamicControl.extend({initKirkiControl:function(){var e,t=this,i=t.container.find("textarea"),n="kirki-editor-"+t.id.replace("[","").replace("]","");wp.editor.initialize(n,{tinymce:{wpautop:!0},quicktags:!0,mediaButtons:!0}),(e=tinyMCE.get(n))&&e.onChange.add(function(n){var a;n.save(),a=e.getContent(),i.val(a).trigger("change"),wp.customize.instance(t.id).set(a)})}}),wp.customize.controlConstructor["kirki-fontawesome"]=wp.customize.kirkiDynamicControl.extend({initKirkiControl:function(){var e,t,i=this,n=this.container.find("select"),a=jQuery.parseJSON(fontAwesomeJSON),r={data:[],escapeMarkup:function(e){return e},templateResult:function(e){return'<i class="fa fa-lg fa-'+e.id+'" aria-hidden="true"></i> '+e.text},templateSelection:function(e){return'<i class="fa fa-lg fa-'+e.id+'" aria-hidden="true"></i> '+e.text}};_.each(a.icons,function(e){r.data.push({id:e.id,text:e.name})}),(t=jQuery(n).selectWoo(r)).on("change",function(){e=jQuery(this).val(),i.setting.set(e)}),t.val(i.setting._value).trigger("change")}}),wp.customize.controlConstructor["kirki-image"]=wp.customize.Control.extend({ready:function(){"use strict";!_.isUndefined(window.kirkiControlLoader)&&_.isFunction(kirkiControlLoader)?kirkiControlLoader(this):this.initKirkiControl()},initKirkiControl:function(){var e=this,t=e.getValue(),i=_.isUndefined(e.params.choices)||_.isUndefined(e.params.choices.save_as)?"url":e.params.choices.save_as,n=e.container.find(".placeholder, .thumbnail"),a="array"===i?t.url:t,r=e.container.find(".image-upload-remove-button"),s=e.container.find(".image-default-button");e.container.find(".kirki-controls-loading-spinner").hide(),"id"!==i&&"ID"!==i||""===t||wp.media.attachment(t).fetch().then(function(){setTimeout(function(){var e=wp.media.attachment(t).get("url");n.removeClass().addClass("thumbnail thumbnail-image").html('<img src="'+e+'" alt="" />')},700)}),("url"===i&&""!==t||"array"===i&&!_.isUndefined(t.url)&&""!==t.url)&&e.container.find("image-default-button").hide(),("url"===i&&""===t||"array"===i&&(_.isUndefined(t.url)||""===t.url))&&r.hide(),t===e.params.default&&e.container.find("image-default-button").hide(),""!==a&&n.removeClass().addClass("thumbnail thumbnail-image").html('<img src="'+a+'" alt="" />'),e.container.on("click",".image-upload-button",function(t){var a=wp.media({multiple:!1}).open().on("select",function(){var t=a.state().get("selection").first(),o=t.toJSON().sizes.full.url;_.isUndefined(t.toJSON().sizes.medium)?_.isUndefined(t.toJSON().sizes.thumbnail)||(o=t.toJSON().sizes.thumbnail.url):o=t.toJSON().sizes.medium.url,"array"===i?(e.saveValue("id",t.toJSON().id),e.saveValue("url",t.toJSON().sizes.full.url),e.saveValue("width",t.toJSON().width),e.saveValue("height",t.toJSON().height)):"id"===i?e.saveValue("id",t.toJSON().id):e.saveValue("url",t.toJSON().sizes.full.url),n.length&&n.removeClass().addClass("thumbnail thumbnail-image").html('<img src="'+o+'" alt="" />'),r.length&&(r.show(),s.hide())});t.preventDefault()}),e.container.on("click",".image-upload-remove-button",function(t){var i,n,a;t.preventDefault(),e.saveValue("id",""),e.saveValue("url",""),e.saveValue("width",""),e.saveValue("height",""),i=e.container.find(".placeholder, .thumbnail"),n=e.container.find(".image-upload-remove-button"),a=e.container.find(".image-default-button"),i.length&&i.removeClass().addClass("placeholder").html("No file selected"),n.length&&(n.hide(),jQuery(a).hasClass("button")&&a.show())}),e.container.on("click",".image-default-button",function(t){var i,n,a;t.preventDefault(),e.saveValue("url",e.params.default),i=e.container.find(".placeholder, .thumbnail"),n=e.container.find(".image-upload-remove-button"),a=e.container.find(".image-default-button"),i.length&&i.removeClass().addClass("thumbnail thumbnail-image").html('<img src="'+e.params.default+'" alt="" />'),n.length&&(n.show(),a.hide())})},getValue:function(){var e=this.setting._value;return"array"===(_.isUndefined(this.params.choices)||_.isUndefined(this.params.choices.save_as)?"url":this.params.choices.save_as)&&_.isString(e)&&(e={url:e}),e},saveValue:function(e,t){var i=this.setting._value;if("array"===(_.isUndefined(this.params.choices)||_.isUndefined(this.params.choices.save_as)?"url":this.params.choices.save_as))return _.isString(i)&&(i={}),i[e]=t,this.setting.set(i),void this.container.find("button").trigger("change");this.setting.set(t),this.container.find("button").trigger("change")}}),wp.customize.controlConstructor["kirki-multicheck"]=wp.customize.kirkiDynamicControl.extend({initKirkiControl:function(){var e=this;e.container.on("change","input",function(){var t=[],i=0;jQuery.each(e.params.choices,function(n){e.container.find('input[value="'+n+'"]').is(":checked")&&(t[i]=n,i++)}),e.setting.set(t)})}}),wp.customize.controlConstructor["kirki-multicolor"]=wp.customize.Control.extend({ready:function(){"use strict";!_.isUndefined(window.kirkiControlLoader)&&_.isFunction(kirkiControlLoader)?kirkiControlLoader(this):this.initKirkiControl()},initKirkiControl:function(){"use strict";function e(e,t,i){var a=e.container.find(".multicolor-index-"+i),s={target:r[0],change:function(){setTimeout(function(){e.saveValue(i,a.val()),e.container.find(".multicolor-index-"+i).trigger("change")},100)}};_.isObject(n.irisArgs)&&_.each(n.irisArgs,function(e,t){s[t]=e}),a.wpColorPicker(s)}for(var t,i,n=this.params.choices,a=Object.keys(n),r=(this.params.value,this.container.find(".iris-target")),s=0;s<Object.keys(n).length;)e(this,0,a[s]),t=this.container.find(".wp-picker-container .wp-picker-input-wrap"),i=this.container.find(".wp-picker-container .wp-picker-holder"),jQuery(t[0]).detach().appendTo(r[0]),jQuery(i[0]).detach().appendTo(r[0]),s++},saveValue:function(e,t){"use strict";var i=this.container.find(".multicolor-hidden-value"),n=jQuery(i).val(),a=JSON.parse(n);a[e]=t,jQuery(i).attr("value",JSON.stringify(a)).trigger("change"),this.setting.set(a)}}),wp.customize.controlConstructor["kirki-number"]=wp.customize.kirkiDynamicControl.extend({initKirkiControl:function(){var e,t,i,n=this,a=n.setting._value,r="";n.params.choices=_.defaults(n.params.choices,{min:0,max:100,step:1}),(isNaN(a)||""===a)&&(a=0>n.params.choices.min&&0<n.params.choices.max?0:n.params.choices.min),a=parseFloat(a),n.params.choices.step="any"===n.params.choices.step?.001:n.params.choices.step,n.params.choices.min=parseFloat(n.params.choices.min),n.params.choices.max=parseFloat(n.params.choices.max),n.params.choices.step=parseFloat(n.params.choices.step),r+="<label>",n.params.label&&(r+='<span class="customize-control-title">'+n.params.label+"</span>"),n.params.description&&(r+='<span class="description customize-control-description">'+n.params.description+"</span>"),r+='<div class="customize-control-content">',r+="<input "+n.params.inputAttrs+' type="text" '+n.params.link+' value="'+a+'" />',r+='<div class="quantity button minus">-</div>',r+='<div class="quantity button plus">+</div>',r+="</div>",r+="</label>",n.container.html(r),e=n.container.find("input"),t=n.container.find(".plus"),i=n.container.find(".minus"),t.click(function(){var t,i=parseFloat(e.val());t=i>=n.params.choices.max?i:i+n.params.choices.step,e.val(t),e.trigger("change")}),i.click(function(){var t,i=parseFloat(e.val());t=i<=n.params.choices.min?i:i-n.params.choices.step,e.val(t),e.trigger("change")}),this.container.on("change keyup paste click","input",function(){n.setting.set(jQuery(this).val())})}}),wp.customize.controlConstructor["kirki-palette"]=wp.customize.kirkiDynamicControl.extend({}),wp.customize.controlConstructor["kirki-preset"]=wp.customize.kirkiDynamicControl.extend({initKirkiControl:function(){var e,t=this;this.container.on("change","select",function(){e=jQuery(this).val(),t.setting.set(e),jQuery.each(t.params.choices,function(t,i){e===t&&jQuery.each(i.settings,function(e,t){kirkiSetSettingValue.set(e,t)})}),wp.customize.previewer.refresh()})}}),wp.customize.controlConstructor["kirki-radio-buttonset"]=wp.customize.kirkiDynamicControl.extend({}),wp.customize.controlConstructor["kirki-radio-image"]=wp.customize.kirkiDynamicControl.extend({});var RepeaterRow=function(e,t,i,n){"use strict";var a=this;this.rowIndex=e,this.container=t,this.label=i,this.header=this.container.find(".repeater-row-header"),this.header.on("click",function(){a.toggleMinimize()}),this.container.on("click",".repeater-row-remove",function(){a.remove()}),this.header.on("mousedown",function(){a.container.trigger("row:start-dragging")}),this.container.on("keyup change","input, select, textarea",function(e){a.container.trigger("row:update",[a.rowIndex,jQuery(e.target).data("field"),e.target])}),this.setRowIndex=function(e){this.rowIndex=e,this.container.attr("data-row",e),this.container.data("row",e),this.updateLabel()},this.toggleMinimize=function(){this.container.toggleClass("minimized"),this.header.find(".dashicons").toggleClass("dashicons-arrow-up").toggleClass("dashicons-arrow-down")},this.remove=function(){this.container.slideUp(300,function(){jQuery(this).detach()}),this.container.trigger("row:remove",[this.rowIndex])},this.updateLabel=function(){var e,t,i;if("field"===this.label.type&&(e=this.container.find('.repeater-field [data-field="'+this.label.field+'"]'),_.isFunction(e.val)&&""!==(t=e.val())))return _.isUndefined(n.params.fields[this.label.field])||_.isUndefined(n.params.fields[this.label.field].type)||("select"===n.params.fields[this.label.field].type?_.isUndefined(n.params.fields[this.label.field].choices)||_.isUndefined(n.params.fields[this.label.field].choices[e.val()])||(t=n.params.fields[this.label.field].choices[e.val()]):"radio"!==n.params.fields[this.label.field].type&&"radio-image"!==n.params.fields[this.label.field].type||(i=n.selector+' [data-row="'+this.rowIndex+'"] .repeater-field [data-field="'+this.label.field+'"]:checked',t=jQuery(i).val())),void this.header.find(".repeater-row-label").text(t);this.header.find(".repeater-row-label").text(this.label.value+" "+(this.rowIndex+1))},this.updateLabel()};wp.customize.controlConstructor.repeater=wp.customize.Control.extend({ready:function(){"use strict";!_.isUndefined(window.kirkiControlLoader)&&_.isFunction(kirkiControlLoader)?kirkiControlLoader(this):this.initKirkiControl()},initKirkiControl:function(){"use strict";var e,t,i=this,n=this.params.value;i.container.find(".kirki-controls-loading-spinner").hide(),this.settingField=this.container.find("[data-customize-setting-link]").first(),this.setValue([],!1),this.repeaterFieldsContainer=this.container.find(".repeater-fields").first(),this.currentIndex=0,this.rows=[],e=!1,_.isUndefined(this.params.choices.limit)||(e=!(0>=this.params.choices.limit)&&parseInt(this.params.choices.limit,10)),this.container.on("click","button.repeater-add",function(n){n.preventDefault(),!e||i.currentIndex<e?((t=i.addRow()).toggleMinimize(),i.initColorPicker(),i.initSelect(t)):jQuery(i.selector+" .limit").addClass("highlight")}),this.container.on("click",".repeater-row-remove",function(){i.currentIndex--,(!e||i.currentIndex<e)&&jQuery(i.selector+" .limit").removeClass("highlight")}),this.container.on("click keypress",".repeater-field-image .upload-button,.repeater-field-cropped_image .upload-button,.repeater-field-upload .upload-button",function(e){e.preventDefault(),i.$thisButton=jQuery(this),i.openFrame(e)}),this.container.on("click keypress",".repeater-field-image .remove-button,.repeater-field-cropped_image .remove-button",function(e){e.preventDefault(),i.$thisButton=jQuery(this),i.removeImage(e)}),this.container.on("click keypress",".repeater-field-upload .remove-button",function(e){e.preventDefault(),i.$thisButton=jQuery(this),i.removeFile(e)}),this.repeaterTemplate=_.memoize(function(){var e={evaluate:/<#([\s\S]+?)#>/g,interpolate:/\{\{\{([\s\S]+?)\}\}\}/g,escape:/\{\{([^\}]+?)\}\}(?!\})/g,variable:"data"};return function(t){return _.template(i.container.find(".customize-control-repeater-content").first().html(),null,e)(t)}}),n.length&&_.each(n,function(e){t=i.addRow(e),i.initColorPicker(),i.initSelect(t,e)}),this.setValue(n,!0,!0),this.repeaterFieldsContainer.sortable({handle:".repeater-row-header",update:function(){i.sort()}})},openFrame:function(e){"use strict";wp.customize.utils.isKeydownButNotEnterEvent(e)||(this.$thisButton.closest(".repeater-field").hasClass("repeater-field-cropped_image")?this.initCropperFrame():this.initFrame(),this.frame.open())},initFrame:function(){"use strict";var e=this.getMimeType();this.frame=wp.media({states:[new wp.media.controller.Library({library:wp.media.query({type:e}),multiple:!1,date:!1})]}),this.frame.on("select",this.onSelect,this)},initCropperFrame:function(){"use strict";var e=this.$thisButton.siblings("input.hidden-field").attr("data-field"),t=this.getMimeType();_.isString(e)&&""!==e&&_.isObject(this.params.fields[e])&&"cropped_image"===this.params.fields[e].type&&["width","height","flex_width","flex_height"].forEach(function(t){_.isUndefined(this.params.fields[e][t])||(this.params[t]=this.params.fields[e][t])}.bind(this)),this.frame=wp.media({button:{text:"Select and Crop",close:!1},states:[new wp.media.controller.Library({library:wp.media.query({type:t}),multiple:!1,date:!1,suggestedWidth:this.params.width,suggestedHeight:this.params.height}),new wp.media.controller.CustomizeImageCropper({imgSelectOptions:this.calculateImageSelectOptions,control:this})]}),this.frame.on("select",this.onSelectForCrop,this),this.frame.on("cropped",this.onCropped,this),this.frame.on("skippedcrop",this.onSkippedCrop,this)},onSelect:function(){"use strict";var e=this.frame.state().get("selection").first().toJSON();this.$thisButton.closest(".repeater-field").hasClass("repeater-field-upload")?this.setFileInRepeaterField(e):this.setImageInRepeaterField(e)},onSelectForCrop:function(){"use strict";var e=this.frame.state().get("selection").first().toJSON();this.params.width!==e.width||this.params.height!==e.height||this.params.flex_width||this.params.flex_height?this.frame.setState("cropper"):this.setImageInRepeaterField(e)},onCropped:function(e){"use strict";this.setImageInRepeaterField(e)},calculateImageSelectOptions:function(e,t){"use strict";var i,n,a,r=t.get("control"),s=!!parseInt(r.params.flex_width,10),o=!!parseInt(r.params.flex_height,10),c=e.get("width"),l=e.get("height"),u=parseInt(r.params.width,10),d=parseInt(r.params.height,10),p=u/d,h=c,f=l;return t.set("canSkipCrop",!r.mustBeCropped(s,o,u,d,c,l)),h/f>p?u=(d=f)*p:d=(u=h)/p,i=(h-u)/2,n=(f-d)/2,a={handles:!0,keys:!0,instance:!0,persistent:!0,imageWidth:c,imageHeight:l,x1:i,y1:n,x2:u+i,y2:d+n},!1===o&&!1===s&&(a.aspectRatio=u+":"+d),!1===o&&(a.maxHeight=d),!1===s&&(a.maxWidth=u),a},mustBeCropped:function(e,t,i,n,a,r){"use strict";return!(!0===e&&!0===t||!0===e&&n===r||!0===t&&i===a||i===a&&n===r||a<=i)},onSkippedCrop:function(){"use strict";var e=this.frame.state().get("selection").first().toJSON();this.setImageInRepeaterField(e)},setImageInRepeaterField:function(e){"use strict";var t=this.$thisButton.closest(".repeater-field-image,.repeater-field-cropped_image");t.find(".kirki-image-attachment").html('<img src="'+e.url+'">').hide().slideDown("slow"),t.find(".hidden-field").val(e.id),this.$thisButton.text(this.$thisButton.data("alt-label")),t.find(".remove-button").show(),t.find("input, textarea, select").trigger("change"),this.frame.close()},setFileInRepeaterField:function(e){"use strict";var t=this.$thisButton.closest(".repeater-field-upload");t.find(".kirki-file-attachment").html('<span class="file"><span class="dashicons dashicons-media-default"></span> '+e.filename+"</span>").hide().slideDown("slow"),t.find(".hidden-field").val(e.id),this.$thisButton.text(this.$thisButton.data("alt-label")),t.find(".upload-button").show(),t.find(".remove-button").show(),t.find("input, textarea, select").trigger("change"),this.frame.close()},getMimeType:function(){"use strict";var e=this.$thisButton.siblings("input.hidden-field").attr("data-field");return _.isString(e)&&""!==e&&_.isObject(this.params.fields[e])&&"upload"===this.params.fields[e].type&&!_.isUndefined(this.params.fields[e].mime_type)?this.params.fields[e].mime_type:"image"},removeImage:function(e){"use strict";var t,i;wp.customize.utils.isKeydownButNotEnterEvent(e)||(i=(t=this.$thisButton.closest(".repeater-field-image,.repeater-field-cropped_image,.repeater-field-upload")).find(".upload-button"),t.find(".kirki-image-attachment").slideUp("fast",function(){jQuery(this).show().html(jQuery(this).data("placeholder"))}),t.find(".hidden-field").val(""),i.text(i.data("label")),this.$thisButton.hide(),t.find("input, textarea, select").trigger("change"))},removeFile:function(e){"use strict";var t,i;wp.customize.utils.isKeydownButNotEnterEvent(e)||(i=(t=this.$thisButton.closest(".repeater-field-upload")).find(".upload-button"),t.find(".kirki-file-attachment").slideUp("fast",function(){jQuery(this).show().html(jQuery(this).data("placeholder"))}),t.find(".hidden-field").val(""),i.text(i.data("label")),this.$thisButton.hide(),t.find("input, textarea, select").trigger("change"))},getValue:function(){"use strict";return JSON.parse(decodeURI(this.setting.get()))},setValue:function(e,t,i){"use strict";var n=e,a=[];i&&(jQuery.each(this.params.fields,function(e,t){"image"!==t.type&&"cropped_image"!==t.type&&"upload"!==t.type||a.push(e)}),jQuery.each(e,function(e,t){jQuery.each(a,function(i,a){_.isUndefined(t[a])||_.isUndefined(t[a].id)||(n[e][a]=t[a].id)})})),this.setting.set(encodeURI(JSON.stringify(n))),t&&this.settingField.trigger("change")},addRow:function(e){"use strict";var t,i,n,a=this,r=a.repeaterTemplate(),s=this.getValue(),o={};if(r){if(t=jQuery.extend(!0,{},a.params.fields),e)for(n in e)e.hasOwnProperty(n)&&t.hasOwnProperty(n)&&(t[n].default=e[n]);t.index=this.currentIndex,r=r(t),(i=new RepeaterRow(a.currentIndex,jQuery(r).appendTo(a.repeaterFieldsContainer),a.params.row_label,a)).container.on("row:remove",function(e,t){a.deleteRow(t)}),i.container.on("row:update",function(e,t,n,r){a.updateField.call(a,e,t,n,r),i.updateLabel()}),this.rows[this.currentIndex]=i;for(n in t)t.hasOwnProperty(n)&&(o[n]=t[n].default);return s[this.currentIndex]=o,this.setValue(s,!0),this.currentIndex++,i}},sort:function(){"use strict";var e=this,t=this.repeaterFieldsContainer.find(".repeater-row"),i=[],n=e.getValue(),a=[],r=[];t.each(function(e,t){i.push(jQuery(t).data("row"))}),jQuery.each(i,function(t,i){a[t]=e.rows[i],a[t].setRowIndex(t),r[t]=n[i]}),e.rows=a,e.setValue(r)},deleteRow:function(e){"use strict";var t,i=this.getValue();i[e]&&this.rows[e]&&(delete i[e],delete this.rows[e],this.setValue(i,!0));for(t in this.rows)this.rows.hasOwnProperty(t)&&this.rows[t]&&(this.rows[t].updateLabel(),0)},updateField:function(e,t,i,n){"use strict";var a,r,s;this.rows[t]&&this.params.fields[i]&&(a=this.params.fields[i].type,r=this.rows[t],s=this.getValue(),n=jQuery(n),_.isUndefined(s[r.rowIndex][i])||(s[r.rowIndex][i]="checkbox"===a?n.is(":checked"):n.val(),this.setValue(s,!0)))},initColorPicker:function(){"use strict";var e=this,t=e.container.find(".color-picker-hex"),i={},n=t.data("field");_.isUndefined(n)||_.isUndefined(e.params.fields[n])||_.isUndefined(e.params.fields[n].palettes)||!_.isObject(e.params.fields[n].palettes)||(i.palettes=e.params.fields[n].palettes),i.change=function(t,i){var n=jQuery(t.target),a=n.closest(".repeater-row").data("row"),r=e.getValue();r[a][n.data("field")]=i.color.toString(),e.setValue(r,!0)},0!==t.length&&t.wpColorPicker(i)},initSelect:function(e,t){"use strict";var i,n,a=this,r=e.container.find(".repeater-field select"),s={};0!==r.length&&(i=r.data("field"),"undefed"!==(n=jQuery(r).data("multiple"))&&jQuery.isNumeric(n)&&1<(n=parseInt(n,10))&&(s.maximumSelectionLength=n),(t=t||{})[i]=t[i]||"",jQuery(r).selectWoo(s).val(t[i]),this.container.on("change",".repeater-field select",function(e){var t=jQuery(e.target),i=t.closest(".repeater-row").data("row"),n=a.getValue();n[i][t.data("field")]=jQuery(this).val(),a.setValue(n)}))}}),wp.customize.controlConstructor["kirki-slider"]=wp.customize.kirkiDynamicControl.extend({initKirkiControl:function(){var e=this,t="postMessage"===e.setting.transport?"mousemove change":"change",i=e.container.find('input[type="range"]'),n=e.container.find('input[type="text"]'),a=e.setting._value;n.attr("value",a),i.on("mousemove change",function(){n.attr("value",i.val())}),i.on(t,function(){e.setting.set(i.val())}),n.on("input paste change",function(){i.attr("value",n.val()),e.setting.set(n.val())}),e.container.find(".slider-reset").on("click",function(){n.attr("value",e.params.default),i.attr("value",e.params.default),e.setting.set(n.val())})}}),wp.customize.controlConstructor["kirki-sortable"]=wp.customize.Control.extend({ready:function(){"use strict";!_.isUndefined(window.kirkiControlLoader)&&_.isFunction(kirkiControlLoader)?kirkiControlLoader(this):this.initKirkiControl()},initKirkiControl:function(){"use strict";var e=this;e.container.find(".kirki-controls-loading-spinner").hide(),e.sortableContainer=e.container.find("ul.sortable").first(),e.sortableContainer.sortable({stop:function(){e.updateValue()}}).disableSelection().find("li").each(function(){jQuery(this).find("i.visibility").click(function(){jQuery(this).toggleClass("dashicons-visibility-faint").parents("li:eq(0)").toggleClass("invisible")})}).click(function(){e.updateValue()})},updateValue:function(){"use strict";var e=[];this.sortableContainer.find("li").each(function(){jQuery(this).is(".invisible")||e.push(jQuery(this).data("value"))}),this.setting.set(e)}}),wp.customize.controlConstructor["kirki-switch"]=wp.customize.kirkiDynamicControl.extend({initKirkiControl:function(){"use strict";var e=this,t=e.setting._value;this.container.on("change","input",function(){t=!!jQuery(this).is(":checked"),e.setting.set(t)})}}),wp.customize.controlConstructor["kirki-toggle"]=wp.customize.kirkiDynamicControl.extend({initKirkiControl:function(){var e=this,t=e.setting._value;this.container.on("change","input",function(){t=!!jQuery(this).is(":checked"),e.setting.set(t)})}}),wp.customize.controlConstructor["kirki-typography"]=wp.customize.Control.extend({ready:function(){"use strict";!_.isUndefined(window.kirkiControlLoader)&&_.isFunction(kirkiControlLoader)?kirkiControlLoader(this):this.initKirkiControl()},initKirkiControl:function(){"use strict";var e,t=this,i=t.getValue();t.renderFontSelector(),t.renderBackupFontSelector(),t.renderVariantSelector(),t.renderSubsetSelector(),t.params.default["font-size"]&&this.container.on("change keyup paste",".font-size input",function(){t.saveValue("font-size",jQuery(this).val())}),t.params.default["line-height"]&&this.container.on("change keyup paste",".line-height input",function(){t.saveValue("line-height",jQuery(this).val())}),t.params.default["margin-top"]&&this.container.on("change keyup paste",".margin-top input",function(){t.saveValue("margin-top",jQuery(this).val())}),t.params.default["margin-bottom"]&&this.container.on("change keyup paste",".margin-bottom input",function(){t.saveValue("margin-bottom",jQuery(this).val())}),t.params.default["letter-spacing"]&&(i["letter-spacing"]=jQuery.isNumeric(i["letter-spacing"])?i["letter-spacing"]+"px":i["letter-spacing"],this.container.on("change keyup paste",".letter-spacing input",function(){i["letter-spacing"]=jQuery.isNumeric(jQuery(this).val())?jQuery(this).val()+"px":jQuery(this).val(),t.saveValue("letter-spacing",i["letter-spacing"])})),t.params.default["word-spacing"]&&this.container.on("change keyup paste",".word-spacing input",function(){t.saveValue("word-spacing",jQuery(this).val())}),t.params.default["text-align"]&&this.container.on("change",".text-align input",function(){t.saveValue("text-align",jQuery(this).val())}),t.params.default["text-transform"]&&jQuery(t.selector+" .text-transform select").selectWoo().on("change",function(){t.saveValue("text-transform",jQuery(this).val())}),t.params.default.color&&(e=this.container.find(".kirki-color-control")).wpColorPicker({change:function(){setTimeout(function(){t.saveValue("color",e.val())},100)}})},renderFontSelector:function(){var e,t=this,i=t.selector+" .font-family select",n=[],a=[],r=[],s=t.getValue(),o=t.getFonts();_.isUndefined(o.standard)||_.each(o.standard,function(e){a.push({id:e.family.replace(/&quot;/g,"&#39"),text:e.label})}),_.isUndefined(o.standard)||_.each(o.google,function(e){r.push({id:e.family,text:e.label})}),n=[{text:"Standard Fonts",children:a},{text:"Google Fonts",children:r}],e=jQuery(i).selectWoo({data:n}),s["font-family"]&&e.val(s["font-family"].replace(/'/g,'"')).trigger("change"),e.on("change",function(){t.saveValue("font-family",jQuery(this).val()),t.renderBackupFontSelector(),t.renderVariantSelector(),t.renderSubsetSelector()})},renderBackupFontSelector:function(){var e,t=this,i=t.selector+" .font-backup select",n=[],a=t.getValue(),r=a["font-family"],s=t.getVariants(r),o=t.getFonts();(_.isUndefined(a["font-backup"])||null===a["font-backup"])&&(a["font-backup"]=""),!1!==s?jQuery(t.selector+" .font-backup").show():jQuery(t.selector+" .font-backup").hide(),_.isUndefined(o.standard)||_.each(o.standard,function(e){n.push({id:e.family.replace(/&quot;/g,"&#39"),text:e.label})}),e=jQuery(i).selectWoo({data:n}),void 0!==a["font-backup"]&&e.val(a["font-backup"].replace(/'/g,'"')).trigger("change"),e.on("change",function(){t.saveValue("font-backup",jQuery(this).val())})},renderVariantSelector:function(){var e,t,i,n=this,a=n.getValue(),r=a["font-family"],s=n.getVariants(r),o=n.selector+" .variant select",c=[],l=!1;!1!==s?(jQuery(n.selector+" .variant").show(),_.each(s,function(e){a.variant===e.id&&(l=!0),c.push({id:e.id,text:e.label})}),l||(a.variant="regular"),jQuery(o).hasClass("select2-hidden-accessible")&&(jQuery(o).selectWoo("destroy"),jQuery(o).empty()),(t=jQuery(o).selectWoo({data:c})).val(a.variant).trigger("change"),t.on("change",function(){n.saveValue("variant",jQuery(this).val()),e=_.isString(a.variant)?a.variant.match(/\d/g):"400",e=_.isObject(e)?e.join(""):"400",i=-1!==a.variant.indexOf("italic")?"italic":"normal",n.saveValue("font-weight",e),n.saveValue("font-style",i)})):jQuery(n.selector+" .variant").hide()},renderSubsetSelector:function(){var e,t=this,i=t.getValue(),n=i["font-family"],a=t.getSubsets(n),r=t.selector+" .subsets select",s=[],o=i.subsets;!1!==a?(jQuery(t.selector+" .subsets").show(),_.each(a,function(e){_.isObject(o)&&-1===o.indexOf(e.id)&&(o=_.reject(o,function(t){return t===e.id})),s.push({id:e.id,text:e.label})})):jQuery(t.selector+" .subsets").hide(),jQuery(r).hasClass("select2-hidden-accessible")&&(jQuery(r).selectWoo("destroy"),jQuery(r).empty()),(e=jQuery(r).selectWoo({data:s})).val(o).trigger("change"),e.on("change",function(){t.saveValue("subsets",jQuery(this).val())})},getFonts:function(){return _.isUndefined(window["kirkiFonts"+this.id])?"undefined"!=typeof kirkiAllFonts?kirkiAllFonts:{google:[],standard:[]}:window["kirkiFonts"+this.id]},getVariants:function(e){var t=this.getFonts(),i=!1;return _.each(t.standard,function(t){if(e&&t.family===e.replace(/'/g,'"'))return i=t.variants,t.variants}),_.each(t.google,function(t){if(t.family===e)return i=t.variants,t.variants}),i},getSubsets:function(e){var t=!1,i=this.getFonts();return _.each(i.google,function(i){i.family===e&&(t=i.subsets)}),t},getValue:function(){"use strict";var e=this.container.find(".typography-hidden-value"),t=jQuery(e).val();return JSON.parse(t)},saveValue:function(e,t){"use strict";var i=this.container.find(".typography-hidden-value"),n=jQuery(i).val(),a=JSON.parse(n);a[e]=t,wp.customize.control(this.id).setting.set(a),jQuery(i).attr("value",JSON.stringify(a)).trigger("change")}});
0 ignored issues
show
Unused Code introduced by
The assignment to variable u seems to be never used. Consider removing it.
Loading history...
Unused Code introduced by
The parameter e is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
Bug introduced by
The variable dimensionkirkiL10n seems to be never declared. If this is a global, consider adding a /** global: dimensionkirkiL10n */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
Bug introduced by
The variable t does not seem to be initialized in case "field" === this.label.t...) && "" !== t = e.val() on line 1 is true. Are you sure the function text handles undefined variables?
Loading history...
Unused Code introduced by
The assignment to variable a seems to be never used. Consider removing it.
Loading history...
Coding Style introduced by
Consider using undefined instead of void(0). It is equivalent and more straightforward to read.
Loading history...
Comprehensibility Best Practice introduced by
This re-assigns to the parameter i. Re-assigning to parameters often makes code less readable, consider introducing a new variable instead.
Loading history...
Comprehensibility Best Practice introduced by
This re-assigns to the parameter n. Re-assigning to parameters often makes code less readable, consider introducing a new variable instead.
Loading history...
Coding Style introduced by
As per coding-style, prefer block-scoped variables using let or const which have better semantics than var.

Since ECMAScript 6, you can create block-scoped vars or constants with the keywords let or const. These variables/constants are only valid in the code block where they have been declared.

Consider the following two pieces of code:

if (true)
 {
    var x = "Hello, Stonehenge!";
}

console.log(x); //prints Hello, Stonehenge! to the console

and

if (true)
 {
    let x = "Hello, Stonehenge!";
}

console.log(x); //ReferenceError: x is not defined

The variable is not defined otuside of its block. This limits bleeding of variables into other contexts.

To know more about this ECMA6 feature, look at the MDN pages on let and const.

Loading history...
Bug introduced by
The variable kirkiSetSettingValue does not seem to be initialized in case _.isUndefined(window.kirkiSetSettingValue) on line 1 is false. Are you sure this can never be the case?
Loading history...
Bug introduced by
The variable tinyMCE seems to be never declared. If this is a global, consider adding a /** global: tinyMCE */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
Bug introduced by
The variable ajaxurl seems to be never declared. If this is a global, consider adding a /** global: ajaxurl */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
Complexity Best Practice introduced by
There is no return statement if e && t.family === e.replace(', """) is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
Bug introduced by
The variable kirkiAllFonts seems to be never declared. If this is a global, consider adding a /** global: kirkiAllFonts */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
Comprehensibility introduced by
Usage of the sequence operator is discouraged, since it may lead to obfuscated code.

The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression.

This operator is most often used in for statements.

Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator.

This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements.

var a,b,c;

a = 1, b = 1,  c= 3;

could just as well be written as:

var a,b,c;

a = 1;
b = 1;
c = 3;

To learn more about the sequence operator, please refer to the MDN.

Loading history...
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
Complexity Best Practice introduced by
There is no return statement if t.family === e is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
Comprehensibility Best Practice introduced by
This re-assigns to the parameter e. Re-assigning to parameters often makes code less readable, consider introducing a new variable instead.
Loading history...
Complexity Best Practice introduced by
There is no return statement if r is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
Bug introduced by
The variable kirkiControlLoader seems to be never declared. If this is a global, consider adding a /** global: kirkiControlLoader */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
Bug introduced by
The variable dimensionskirkiL10n seems to be never declared. If this is a global, consider adding a /** global: dimensionskirkiL10n */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
Bug introduced by
The variable r seems to not be initialized for all possible execution paths. Are you sure extend handles undefined variables?
Loading history...
Complexity Coding Style introduced by
You seem to be assigning a new value to the loop variable s here. Please check if this was indeed your intention. Even if it was, consider using another kind of loop instead.
Loading history...
Unused Code introduced by
The assignment to variable n seems to be never used. Consider removing it.
Loading history...
Bug introduced by
The variable kirkiL10n seems to be never declared. If this is a global, consider adding a /** global: kirkiL10n */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
Bug introduced by
The variable fontAwesomeJSON seems to be never declared. If this is a global, consider adding a /** global: fontAwesomeJSON */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
Comprehensibility Best Practice introduced by
This re-assigns to the parameter t. Re-assigning to parameters often makes code less readable, consider introducing a new variable instead.
Loading history...
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...